﻿using Glue;
using Xunit;

namespace GlueTests.RelationContainerTests
{
    public class When_adding_a_relation
    {

        public class GuiPerson { public int Id { get; set; } }
        public class DomainPerson { public int Id { get; set; } }

        private readonly Mapping<DomainPerson, GuiPerson> mapping;

        public When_adding_a_relation()
        {
            mapping = new Mapping<DomainPerson, GuiPerson>();
            mapping.Relate(domain => domain.Id, gui => gui.Id);
        }

        [Fact]
        public void Should_be_a_relation_towards_left()
        {

            var relationsTowardsLeft = mapping.Relations.GetRelationsTowardsLeft();
            Assert.Equal(1,relationsTowardsLeft.Count);
        }

        [Fact]
        public void Should_be_a_relation_towards_right()
        {
            var relationsTowardsRight = mapping.Relations.GetRelationsTowardsRight();
            Assert.Equal(1, relationsTowardsRight.Count);
        }

        [Fact]
        public void Should_be_a_relation_in_AllRelations()
        {
            Assert.Equal(1, mapping.Relations.Count);
        }

        [Fact]
        public void Should_get_it_back_when_asking_for_it()
        {
            Assert.NotNull(mapping.Relations.Get(domain=>domain.Id,gui=>gui.Id));
        }
    }
}
